const { UploadImage } = require('../database/index')
const { getExecutedSql } = require('../logger');
// 导出
module.exports = async (req, res) =>
{
    const file = req.file;
    console.log("=====>", file);
    try {
        // 插入文件信息到数据库，这里假设你已经设置好了数据库操作的相关模块  
        const uploadImage = await UploadImage.create({
            filename: file.originalname,
            upload_time: new Date()
        });
        const filename = req.file.filename
        res.status(200).send({
            data: {
                uploadImage,
                filename
            },
            meta: {
                msg: "存储成功",
                status: 200
            },
            sql: getExecutedSql()
        })
    } catch (error) {
        res.status(500).send({ message: 'Internal server error', error: error.message });
    }
}